﻿@using HopNguyenCms.Infrastructure
@{
    List<YouTubeVideoQuality> videos = ViewBag.Video;
}

@if (!string.IsNullOrEmpty(ViewBag.Error))
{
    <div class="col-full">
        <div class="video-error">@ViewBag.Error</div>
    </div>
}
@if (videos != null && videos.Any())
{
    var video = videos[0];
    <script> $(document).ready(function () { CreateYoutube('@video.VideoTitle', '@ViewBag.VideoID', '@ViewBag.Time'); @*window.history.pushState({}, "Download video: @Html.Raw(video.VideoTitle)", "http://www.getlinkyoutube.com/watch?v=@(ViewBag.VideoID)");*@ });</script>
    <div class="col-full">
        <div class="video-result">
            <div class="img-video">
                <img src="http://i3.ytimg.com/vi/@(ViewBag.VideoID)/0.jpg" alt="@video.VideoTitle"/>
            </div>
            <div class="video-info">
                <table class="table-video-info">
                    <tbody>
                        <tr>
                            <td class="name">Title:</td>
                            <td>
                                @Html.Raw(video.VideoTitle)
                            </td>
                        </tr>
                        <tr>
                            <td class="name">Duration:</td>
                            <td>@ViewBag.Time</td>
                        </tr>
                        <tr>
                            <td class="name">Watch video:</td>
                            <td><a href="@AppSettings.CurrentDomain/video/@(ViewBag.VideoID).html" target="_blank">@AppSettings.CurrentDomain/video/@(ViewBag.VideoID).html</a></td>
                        </tr>
                    </tbody>
                </table>
                <h3>Download from list below:</h3>
                <ul class="video-downloads">
                    @foreach (var item in videos)
                    {
                        //var videoDimension = WebsiteController.formatSize(item.Dimension);
                        //var videoSize = WebsiteController.formatSizeBinary(item.VideoSize);
                        <li><a href="@item.DownloadUrl" title="Click to download">Download @item.Extention</a></li>
                    }
                </ul>
            </div>
        </div>

    </div>
}